#ifndef INCLUDE_REFLECTION_REFLECTION_HPP
#define INCLUDE_REFLECTION_REFLECTION_HPP

#include <iostream>

#define HAS_FUNC(func, name)                                        \
    template<typename T, typename Sign>                                 \
    struct name {                                                       \
        typedef char yes[1];                                            \
        typedef char no [2];                                            \
        template <typename U, U> struct type_check;                     \
        template <typename _1> static yes &chk(type_check<Sign, &_1::func > *); \
        template <typename   > static no  &chk(...);                    \
        static bool const value = sizeof(chk<T>(0)) == sizeof(yes);     \
    }

namespace robos{ 
    template<class T>
    auto serialize_imp(std::ostream& os, T const& obj, int)
        -> decltype(os << obj, void())
    {
      os << obj;
    }
    
    template<class T>
    auto serialize_imp(std::ostream& os, T const& obj, long)
        -> decltype(obj.stream(os), void())
    {
      obj.stream(os);
    }
    
    template<class T>
    auto serialize(std::ostream& os, T const& obj)
        -> decltype(serialize_imp(os, obj, 0), void())
    {
      serialize_imp(os, obj, 0);
    }

};


#endif
